package com.aaa.dao;


import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface L_FieldTripDao {

    @Select("<script>select * from field_trip" +
            " where 1=1 " +
            " <if test=\"inspection!=null and inspection!=''\"> and inspection like concat('%',#{inspection},'%')</if> " +
            " limit #{start},#{pageSize}</script>")
    List<Map> getAll(Map map);

    @Select("<script>select count(id) from field_trip " +
            " where 1=1 <if test=\"id!=null and id!=0\"> and id =#{id}</if>" +
            " <if test=\"inspection!=null and inspection!=''\"> and inspection like concat('%',#{inspection},'%')</if></script>")
    Integer getCount(Map map);


    @Select("select name from regist")
    List<Map> DWname();

    @Insert("insert into field_trip(inspection,starttime,score,assessment,state,fieldid)  values(#{danwei},NOW(),#{region},#{textarea},0,#{id}) " )
    Integer xinzeng(Map map);

    @Delete("delete from field_trip where id=#{id}")
    void del(Integer id);

    @Select("select * from field_trip where inspection=#{danwei} and assessment=#{textarea}")
    List<Map> chachong(Map map);

    @Select("select inscore from regist where name=#{danwei}")
    List<Map> inscore(Map map);

    @Update("update  regist a  set  a.inscore=#{region} where a.`name`=#{danwei} ")
    void addinscore(Map map);

    @Update("update  regist a  set  a.inscore=a.inscore+#{region} where a.`name`=#{danwei} ")
    void setinscore(Map map);
}
